<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/


/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');
});


Route::group(['middleware' => ['web'], 'namespace' => 'Admin', 'prefix' => 'admin'], function () {
    Route::auth();

    //菜单权限部分
    Route::get('/index',                         ['as' => 'admin.home',                      'uses' => 'HomeController@index']);
    Route::resource('admin_user',               'AdminUserController');
    Route::resource('role',                     'RoleController');
    Route::resource('permission',               'PermissionController');
    Route::resource('blog',                     'BlogController');    
    Route::post('admin_user/destroyall',        ['as'=>'admin.admin_user.destroy.all',      'uses'=>'AdminUserController@destroyAll']);
    Route::get('admin_user/password/{id}',      ['as'=>'admin.admin_user.password',         'uses'=>'AdminUserController@password']);
    Route::post('admin_user/password_post/{id}',['as'=>'admin.admin_user.password_post',    'uses'=>'AdminUserController@password_post']);
    Route::post('role/destroyall',              ['as'=>'admin.role.destroy.all',            'uses'=>'RoleController@destroyAll']);
    Route::get('role/{id}/permissions',         ['as'=>'admin.role.permissions',            'uses'=>'RoleController@permissions']);
    Route::post('role/{id}/permissions',        ['as'=>'admin.role.permissions',            'uses'=>'RoleController@storePermissions']);
    Route::post('permission/destroyall',        ['as'=>'admin.permission.destroy.all',      'uses'=>'PermissionController@destroyAll']);
    // END
    Route::get('test',                          ['as'=>'admin.test.list',                   'uses'=>'TestController@index']);


    // 病区管理
    Route::resource('bingqu',                  'BingquController');
    Route::resource('shebei',                  'ShebeiController');
    Route::get('bingren/jiechu',                ['as'=>'admin.bingren.jiechu',      'uses'=>'BingrenController@jiechu']);
    Route::get('bingren/get_bingchuang',        ['as'=>'admin.bingren.get_bingchuang',      'uses'=>'BingrenController@get_bingchuang']);
    Route::get('bingren/tiwen/{id}',                ['as'=>'admin.bingren.tiwen',      'uses'=>'BingrenController@tiwen']);
    Route::get('bingren/jiechu/{id}',                ['as'=>'admin.bingren.jiechu',      'uses'=>'BingrenController@jiechu']);
    Route::post('bingren/jiechu_post',                ['as'=>'admin.bingren.jiechu_post',      'uses'=>'BingrenController@jiechu_post']);
    Route::resource('bingren',                 'BingrenController');
    Route::any('zhuyuan/index',                 ['as'=>'admin.zhuyuan.index',      'uses'=>'BingrenController@zhuyuan']);
    Route::any('jujia/index',                   ['as'=>'admin.jujia.index',      'uses'=>'BingrenController@jujia']);


    Route::get('data/index',        ['as'=>'admin.data.index',      'uses'=>'DataController@index']);


});


Route::get('/admin', function () {
    return view('admin.welcome');
});

Route::get('/', function () {
    return view('welcome');
});
Route::get('home/index', 'HomeController@index');
Route::post('add_tiwen', 'HomeController@add_tiwen');

//
//Route::group(['middleware' => 'web'], function () {
//    Route::auth();
//
//    Route::get('/home', 'HomeController@index');
//});

Route::post('api/get_data', 'Api\ApiController@get_data');
Route::post('api/get_userinfo', 'Api\ApiController@get_userinfo');
Route::get('api/test', 'Api\ApiController@test');
Route::get('api/test_userinfo', 'Api\ApiController@test_userinfo');